﻿using System.Windows;

namespace TemperatureWP.Utilities
{
    // Source: http://visualstudiomagazine.com/articles/2011/06/27/wcmob_loading-progress-display.aspx
    public struct VisualBoolean
    {
        private readonly static VisualBoolean True = new VisualBoolean { IsTrue = true };
        private readonly static VisualBoolean False = new VisualBoolean { IsTrue = false };

        public bool IsTrue { get; private set; }

        public bool IsFalse
        {
            get
            {
                return !IsTrue;
            }
        }

        public Visibility IsTrueVisibility
        {
            get { return IsTrue ? Visibility.Visible : Visibility.Collapsed; }
        }

        public Visibility IsFalseVisibility
        {
            get { return IsFalse ? Visibility.Visible : Visibility.Collapsed; }
        }

        public static implicit operator VisualBoolean(bool isTrue)
        {
            return isTrue ? True : False;
        }

        public static implicit operator bool(VisualBoolean visualBoolean)
        {
            return visualBoolean.IsTrue;
        }
    }
}
